; Installer script for MSys
; $VER: Install MSys 42.2 (9.2.97)

(complete 0)

(set #default-dest "C:")

(set #comm-dir "C/")

; ***************************************************************************
; English strings

(set #bad-kick
	(cat "You must have AmigaDOS 2.04 or higher to use MSys!"))

(set #welcome
	(cat "\nMSys installation\n\n\n"
       "This script installs MSys 1.1\n"
       "on your Amiga.\n\n\n\n"
       "MSys package is\n"
       "Copyright  1996-97 Michal Letowski\n"
       "All rights reserved.\n\n"))

(set #where-commands
	(cat "Where should MSys be installed?"))

(set #where-help
	(cat "\nBy default, all CLI commands are placed in C:"
       " logical directory. Hovewer, the commands can be"
       " placed in any directory, as long as it is added to"
       " search path by using \"Path\" command.\n\n"))

(set #which-commands
	(cat "Which MSys commands should be installed?"))

(set #which-commands-help
	(cat "\n\n\"Avail\" is an \"Avail\" 40.1 replacement;"
       "\n\n\"LoadWB\" is a \"LoadWB\" 38.9 replacement;"
	     "\n\n\"MakeLink\" is a \"MakeLink\" 37.4 replacement;"
       "\n\n\"Reboot\" is a \"Reboot\" 39.1 replacement;"
	     "\n\n\"RequestChoice\" is a \"RequestChoice\" 39.3 replacement.\n\n\n"))

; ***************************************************************************
; Install MSys

; Check AmigaDOS version
(set #version (/ (getversion) 65536))
(if (< #version 37)
	(
		(abort #bad-kick)
	)
)

(message #welcome)

(welcome)
(set old_level @user-level)

(user 2)
(set #MSys-dir
	(askdir
		(prompt #where-commands)
		(help #where-help)
		(default #default-dest))
)

; Choose commands
(if (< #version 39)
	(
		(set commands
			(askoptions
				(prompt #which-commands)
				(help #which-commands-help @askoptions-help)
				(choices
				  "Avail"
				  "MakeLink"
					"Reboot"
					"RequestChoice")
			)
		)
	)
	(
		(set commands
			(askoptions
				(prompt #which-commands)
				(help #which-commands-help @askoptions-help)
				(choices
				  "Avail"
					"LoadWB"
				  "MakeLink"
					"Reboot"
					"RequestChoice")
			)
		)
	)
)

; Do copy
(user old_level)
(set n 0)
(if (< #version 39)
	(while
		(set comm
			(select n
			  "Avail"
			  "MakeLink"
				"Reboot"
				"RequestChoice"
				"")
		)
		(
			(if (IN commands n)
				(copylib
					(help @copylib-help)
					(source (cat #comm-dir comm))
					(dest #MSys-dir)
					(optional "nofail")
				)
			)
			(set n (+ n 1))
			(complete (* n 25))
		)
	)
; 3.0 Install
	(while
		(set comm
			(select n
			  "Avail"
				"LoadWB"
			  "MakeLink"
				"Reboot"
				"RequestChoice"
				"")
		)
		(
			(if (IN commands n)
				(copylib
					(help @copylib-help)
					(source (cat #comm-dir comm))
					(dest #MSys-dir)
					(optional "nofail")
				)
			)
			(set n (+ n 1))
			(complete (* n 20))
		)
	)
)
(complete 100)

(set @default-dest #MSys-dir)
(exit)
